home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc™ Source Code / Storage / Bento / CM / CMConfig.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-28  |  14.3 KB  |  323 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        CMConfig.h
  3.  
  4.     Contains:    Container Manager Configuration Controls
  5.  
  6.     Written by:    Ira L. Ruben
  7.  
  8.     Owned by:    Ed Lai
  9.  
  10.     Copyright:    © 1994 - 1996 by Apple Computer, Inc., all rights reserved.
  11.  
  12.     Change History (most recent first):
  13.  
  14.          <2>     1/15/96    TJ        Cleaned Up
  15.          <7>     10/9/95    EL        1290781: flag to allow ignoring non-fatal
  16.                                     error.
  17.          <6>     4/25/95    EL        1242376: Separate crash proof for embedded
  18.                                                     and top level container.
  19.          <5>     3/24/95    EL        1226127: add CMCRASH_PROOF.
  20.          <4>     12/9/94    EL        #1182275 Add CMKEEP_CONTINUE_FLAG
  21.          <3>     9/15/94    EL        #1182275 More comment on MinFragmentSize.
  22.          <2>     8/26/94    EL        #1181622 Ownership update.
  23.          <3>      5/9/94    MB        #1162181: Changes necessary to install MMM.
  24.          <2>      2/3/94    EL        Bento File names are now eight chars or
  25.                                     less.
  26.  
  27.     To Do:
  28. */
  29.  
  30. /*---------------------------------------------------------------------------*
  31.  |                                                                           |
  32.  |                            <<< CMConfig.h >>>                             |
  33.  |                                                                           |
  34.  |                 Container Manager Configuration Controls                  |
  35.  |                                                                           |
  36.  |                               Ira L. Ruben                                |
  37.  |                                  8/4/92                                   |
  38.  |                                                                           |
  39.  |                    Copyright Apple Computer, Inc. 1992-1995               |
  40.  |                           All rights reserved.                            |
  41.  |                                                                           |
  42.  *---------------------------------------------------------------------------*
  43.  
  44.  This header is used to defined various "configuration" attributes that control optional
  45.  or alternative versions of various aspects of the Container Manager code.  Some constants
  46.  are also defined here which may be a function of the environment in which the Container
  47.  Manager is run.  Such constants are not in CMAPIEnv.h.h because these also may
  48.  control the way code is generated and this header is not a published header as is the
  49.  case for CMAPIEnv.h.h.
  50. */
  51.  
  52.  
  53. #ifndef __CMCONFIG__
  54. #define __CMCONFIG__
  55.  
  56.  
  57. /*The following macros are used to define call "old" code for support of format 1 TOC
  58.  manipulations.    That is because
  59.  the support of the "old" TOC format is only there TEMPORARILY for Lotus and initial
  60.  format size comparisons with the "new" and more compact TOC format.  To make it easier to
  61.  find and remove the bracketed code, we make these macros stand out.
  62. */
  63.  
  64. #ifndef TOC1_SUPPORT
  65. #define TOC1_SUPPORT 0                    /* Must be explicitly requested as compiler option!            */
  66. #endif
  67.  
  68. #if TOC1_SUPPORT                                /* function call TOC format 1 alternative with result        */
  69. #define USE_TOC_FORMAT_1_ALTERNATIVE(format1Proc, params)    \
  70.     if (((ContainerPtr)container)->majorVersion == 1)                \
  71.         return format1Proc##params
  72. #else
  73. #define USE_TOC_FORMAT_1_ALTERNATIVE(format1Proc, params)    
  74. #endif
  75.  
  76. #if TOC1_SUPPORT                                /* function call TOC format 1 alternative with no result*/
  77. #define USE_TOC_FORMAT_1_ALTERNATIVE1(format1Proc, params)    \
  78.     if (((ContainerPtr)container)->majorVersion == 1)    {                \
  79.         format1Proc##params;                                                                        \
  80.         return;                                                                                                    \
  81.     }
  82. #else
  83. #define USE_TOC_FORMAT_1_ALTERNATIVE1(format1Proc, params)    
  84. #endif
  85.  
  86.  
  87. /*--------------------*
  88.  | Buffering Controls |
  89.  *--------------------*
  90.  
  91.  Some routines buffer their I/O.  The following define the buffer sizes used.  Where 
  92.  indicated, some sizes may be defined as 0 to disable the explicit buffering.  This would
  93.  usually be done if the the I/O is through handlers which do their own buffering so there
  94.  would be n need to do additional buffering by the handler callers.
  95.  
  96.  Unless indicated, these buffers are only allocated during the time they are used. These 
  97.  uses are generally at mutually exclusive times and thus the total space defined is not
  98.  the total space used.
  99.  
  100.  The buffers being defined here are used as the buffer size parameter to  BufferIO.c 's
  101.  cmUseIOBuffer() which allocate the buffers.  The buffering routines will take any
  102.  (reasonable) size.  It does not have to be a multiple of something.  Although that 
  103.  probably would not hurt!
  104. */
  105.  
  106.  
  107. /* The reading and writing the TOC is buffered.  The following defines the buffer size    */
  108. /* used...                                                                                                                                                            */
  109.  
  110. #if TOC1_SUPPORT
  111. #ifndef TOCInputBufSize
  112. #define TOCInputBufSize (0)                    /* This defines the size of the TOC input buffer. It*/
  113. #endif                                                            /* should be a "moderate" size (maybe about 50*24)    */
  114.                                                                         /* chosen as a comprimize to wanting to read large     */
  115.                                                                         /* chunks of TOC and not wanting to read too far         */
  116.                                                                         /* into a "split" TOC which has a public and private*/
  117.                                                                         /*  section when the TOC is used for updating a         */
  118.                                                                         /* target container.                                                                */
  119.                                                                                 
  120.                                                                         /* THIS CAN BE 0.  No explict TOC buffering will be */
  121.                                                                         /* done. It is then assumed that either no buffering*/
  122.                                                                         /* is wanted (why?), or that the handlers do the         */
  123.                                                                         /* buffering.                                                                              */
  124.                                                                         
  125.                                                                         /* If the handlers are doing standard stream I/O,     */
  126.                                                                         /* then presumably a setvbuf() can be done to allow    */
  127.                                                                         /* the stream I/O to do the buffering so none would    */
  128.                                                                         /* be needed to be defined here.                                        */
  129. #endif
  130.  
  131. #ifndef UpdateBufSize
  132. #define UpdateBufSize         512                /* Max size of the updates buffer, i.e., the buffer    */
  133. #endif                                                            /* used to write updating instructions into as value*/
  134.                                                                         /* data.  This can NEVER be 0.  Update instructions    */
  135.                                                                         /* are always buffered because the handlers are not    */
  136.                                                                         /* explicitly used as is the case for TOC I/O.            */
  137.                                                                         
  138.                                                                         /* A "moderate" size should be chosen for this since*/
  139.                                                                         /* the buffer is reused for each object that has        */
  140.                                                                         /* updates associated with it.  It come down to         */
  141.                                                                         /* guessing how much updating will be done to the        */
  142.                                                                         /* values belonging to an object.                                        */
  143.  
  144. #define DefaultTOCBufSize    1                    /* Default TOC output buffer size in units of 1024    */
  145.                                                                         /* bytes. A value of "n" means n*1024 bytes is used    */
  146.                                                                         /* as the TOC output buffer size.  The TOC is             */
  147.                                                                         /* formatted in "blocks" of n*1024 and will never     */
  148.                                                                         /* span (cross) a block boundary.  Padding is added */
  149.                                                                         /* if necessary.  The n here is placed in the             */
  150.                                                                         /* container label and is limited to a maximum value*/
  151.                                                                         /* of 65535 (0xFFFF).                                                                */
  152.                                                                         
  153.                                                                         /* For reading, whatever "n" is found in the label    */
  154.                                                                         /* is used to determine the input TOC buffer size.    */
  155.                                                                         /* Thus, there can be no default for the input             */
  156.                                                                         /* buffer size.                                                                            */
  157.  
  158. #define RefsBufSize                (64*8)        /* Size of the input buffer used to search for             */
  159.                                                                         /* a value's references. See "Reference Shadow List */
  160.                                                                         /* Controls" for a brief description of references.    */
  161.                                                                         /* The value data is formatted as 8-byte CMReference*/
  162.                                                                         /* key/object ID pairs (4 bytes each).  Almost any    */
  163.                                                                         /* reasonable size will do here depending on your        */
  164.                                                                         /* estimate on how heavily references are used.            */
  165.  
  166. /*----------------------*
  167.  | Performance Controls |
  168.  *----------------------*
  169.  
  170.     Some parameters can be used to control the trade off between performance and disk
  171.     space usage. For example if we allows a value to be separated into many value
  172.     segments to use up every possible disk space, we save disk space but the resulting
  173.     performance would suffer because of the fragmentation. So you want to adjust it
  174.     to suit your own need.
  175.  */
  176.  
  177. /* Very often, the same value is being written back. If we know it is unchanged we can    */
  178. /* avoid the write. We can do this by reading the data back and comparing with the new    */
  179. /* data. However, this reading and comparison introduces overhead. So we only want to        */
  180. /* do it if the data size is small. kSizeReadBeforeWrite is the data size limit that we    */
  181. /* would attempt a read before write.                                                                                                        */
  182.  
  183. #ifndef SizeReadBeforeWrite
  184. #define SizeReadBeforeWrite        32
  185. #endif                                                        
  186.  
  187. /* When we are getting space from the free space, we try not to break it up into very        */
  188. /* small segment. MinFragmentSize is the smallest block we try to get unless we are            */
  189. /* asking for less ourselves.                                                                                                                        */
  190. #ifndef MinFragmentSize
  191. #define MinFragmentSize                128
  192. #endif                                                        
  193.  
  194. /* For large blocks, we try not to have more than MaxFragmentCount segments.                        */
  195. /* In reality, we end up with more segments than this. The reason is that if we do not    */
  196. /* get all the space we want, we would ask again. However the second time we ask we         */
  197. /* are asking for the remainder, which is smaller. So if kMaxFragmentCount is 4 and we    */
  198. /* initially ask for 4K, we may not end up with 4 1K segment. Rather we may get back        */
  199. /* blocks of 1K, 0.75K, 0.56K, 0.42K, 0.32K etc.                                                                                */
  200.  
  201. /* We also use this constant to trigger when we need to try to consolidate segments            */
  202. /* Of course this does not means that we can cut it down to this number.                                 */
  203. #ifndef MaxFragmentCount
  204. #define MaxFragmentCount            4
  205. #endif                                                        
  206.  
  207. /*--------------------*
  208.  | Debugging Controls |
  209.  *--------------------*
  210.  
  211.  The following two switches control whether the indicated debugging code should be 
  212.  generated. The first controls the generation of CMDebugging() while the second controls
  213.  the generation of CMDumpTOCStructures() and CMDumpContainerTOC().  These two routines have
  214.  the following actions:
  215.  
  216.  CMDebugging()                    - to set some internal debugging "options"
  217.  CMDumpTOCStructures()    - to dump in-memory TOC as a tree-like format
  218.  CMDumpContainerTOC()        - to read in container TOC and display it in a table format
  219. */
  220.  
  221. #ifndef CMDEBUGGING
  222. #define CMDEBUGGING 0            /* 1 ==> define CMDebugging()                                                                    */
  223. #endif
  224.  
  225. #ifndef CMDUMPTOC
  226. #define CMDUMPTOC 0                /* 1 ==> define CMDumpTOCStructures() and CMDumpContainerTOC()*/
  227. #endif
  228.  
  229.  
  230. /*------------------------------------*
  231.  | Validation and Protection Controls |
  232.  *------------------------------------*
  233.  
  234.  The following two switches control the validation checking code in the Container Manager.
  235.  Validations include checking that CMStartSession() was called and for NULL refNums. There
  236.  is a dynamic switch controlled by CMDebugging() (the switch is in the session global data)
  237.  and a static (compile time) switch to suppress the validation checks entirely.
  238.  
  239.  Remember, suppressing the validation checks removes what little protection the Container
  240.  Manager has.
  241. */
  242.  
  243. #ifndef CMVALIDATE
  244. #define CMVALIDATE 1                        /* 1 ==> generate validation code; 0 ==> don't generate */
  245. #endif
  246.  
  247. #ifndef CMDEFAULT_VALIDATE
  248. #define CMDEFAULT_VALIDATE 1        /* default (initial) dynamic validation switch setting    */
  249. #endif
  250.  
  251.  
  252. /*--------------------------------*
  253.  | Reference Shadow List Controls |
  254.  *--------------------------------*
  255.  
  256.  Object references are "pointers" (i.e., object IDs) to other objects from a value 
  257.  (CMValue) that contains data that refers to those objects.  The data is in the form of a
  258.  CMReference "key" and associated object ID.  The routines in    CMRefOps.c    manipulate
  259.  those key/object (ID) associations.  The associations are maintained in a list as value
  260.  data for a uniquely typed value in a private object "tied" to the value through a pointer
  261.  in the value header.
  262.  
  263.  To increase efficiency, the data is read into memory the first time it's accessed.  From
  264.  that point on, all updates to the actual data are "shadowed" in the in-memory list.  The
  265.  updating can't be avoided (so updating, e.g., touches, etc. work correctly).  But at least
  266.  the searches can be made to not be I/O bound!  This shadow list support is OPTIONAL and
  267.  controlled by the macro variable defined below.  If the variable is defined as 0, no
  268.  shadow list support is provided.  All search operations for a reference will take place
  269.  directly on the value data.  This has the benefit of not requiring additional memory 
  270.  space.  It also could potentially be more efficient depending on the supporting I/O
  271.  handlers.  These are the reasons the shadow list support is optional.
  272. */
  273.  
  274. #ifndef CMSHADOW_LIST
  275. #define CMSHADOW_LIST    0                    /* 1 ==> support reference shadow list                                    */
  276. #endif
  277.  
  278. /*-----------------------*
  279.  | Miscelaneous Controls |
  280.  *-----------------------*
  281.  
  282. */
  283.  
  284. /* If there are multiple value segments, there is a continous flag in all the values
  285.     except the last one as well as value header. A lot of work is needed to maintain
  286.     the flags to make sure that they are correct as segments are being added and
  287.     deleted. The flags are used at close time when the TOC is being written out.
  288.     If we do not use the flags until close time, we may skip the maintenance of
  289.     the flags. At close time we can reconstruct the flag by looking at the value
  290.     list.
  291. */
  292.  
  293. #ifndef CMKEEP_CONTINUE_FLAG
  294. #define CMKEEP_CONTINUE_FLAG    0            /* 1 ==> maintain the continue flag in values                */
  295. #endif
  296.  
  297. /* If there are multiple value segments, there is a continous flag in all the values
  298.     except the last one as well as value header. A lot of work is needed to maintain
  299.     the flags to make sure that they are correct as segments are being added and
  300.     deleted. The flags are used at close time when the TOC is being written out.
  301.     If we do not use the flags until close time, we may skip the maintenance of
  302.     the flags. At close time we can reconstruct the flag by looking at the value
  303.     list.
  304. */
  305. #ifndef CMIGNORE_NONFATAL
  306. #define CMIGNORE_NONFATAL    1                    /* 1 ==> ignore non-fatal errors                */
  307. #endif
  308.  
  309. /* If an error is non-fatal, this flag allows the program to ignore the error and
  310.     continue instead of calling the error handling routine.
  311. */
  312.  
  313. #ifndef CMTOPLEVEL_CRASH_PROOF
  314. #define CMTOPLEVEL_CRASH_PROOF    1                /* 1 ==> make sure don't write over old content                */
  315. #endif
  316.  
  317. #ifndef CMEMBEDDED_CRASH_PROOF
  318. #define CMEMBEDDED_CRASH_PROOF    0                /* 1 ==> make sure don't write over old content                */
  319. #endif
  320.  
  321.  
  322. #endif
  323.